[Go to site: main page, start]

0% found this document useful (0 votes)
36 views5 pages

JavaScript Keywords and Functions Guide

The document provides a comprehensive overview of JavaScript keywords, attributes, and functions, including variable declaration, control flow, loops, error handling, and object-oriented programming. It also covers common built-in functions and methods for alerts, logging, parsing, and manipulating data types such as arrays, strings, and objects. Examples are provided for each keyword and function to illustrate their usage.

Uploaded by

cl3089349
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views5 pages

JavaScript Keywords and Functions Guide

The document provides a comprehensive overview of JavaScript keywords, attributes, and functions, including variable declaration, control flow, loops, error handling, and object-oriented programming. It also covers common built-in functions and methods for alerts, logging, parsing, and manipulating data types such as arrays, strings, and objects. Examples are provided for each keyword and function to illustrate their usage.

Uploaded by

cl3089349
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Complete JavaScript Keywords, Attributes, and Functions

Keywords

let / const / var

Used to declare variables.

Example: let x = 5; const y = 10;

if / else / switch

Conditional branching in code.

Example: if (x > y) {...}

for / while / do...while

Loops for iteration.

Example: for (let i = 0; i < 10; i++) {...}

break / continue

Control loop flow.

Example: if (i === 5) break;

return

Returns value from function.

Example: return x + y;

try / catch / finally

Error handling.

Example: try { ... } catch(e) { ... }


Complete JavaScript Keywords, Attributes, and Functions

throw

Throws an error manually.

Example: throw new Error('message');

function

Defines a function.

Example: function add(a, b) { return a + b; }

class / extends / super

For object-oriented programming.

Example: class Car extends Vehicle {...}

import / export

Used in modules to import/export code.

Example: export default function() {...}

await / async

Used for asynchronous code.

Example: async function() { await fetch(url); }

typeof / instanceof

Type checking.

Example: typeof x === 'string';


Complete JavaScript Keywords, Attributes, and Functions

new

Creates instance of object.

Example: let obj = new Object();

delete

Deletes object property.

Example: delete [Link];

this

Refers to current object context.

Example: [Link] = 'John';

Common Built-in Functions & Methods

alert()

Displays an alert dialog.

Example: alert('Hello');

[Link]()

Logs output to console.

Example: [Link](x);

parseInt(), parseFloat()

Converts strings to numbers.

Example: parseInt('123');
Complete JavaScript Keywords, Attributes, and Functions

setTimeout(), setInterval()

Timer functions.

Example: setTimeout(() => {}, 1000);

Array methods

forEach, map, filter, reduce etc.

Example: [Link](x => x * 2);

String methods

Includes length, toUpperCase, slice, etc.

Example: 'abc'.toUpperCase();

Object methods

[Link], values, entries, etc.

Example: [Link](obj);

JSON methods

parse, stringify.

Example: [Link]({name: 'John'});

Math object

Provides math functions like [Link](), random(), etc.

Example: [Link]([Link]() * 10);


Complete JavaScript Keywords, Attributes, and Functions

Date object

Handles date/time.

Example: new Date().toLocaleDateString();

fetch()

Makes network requests.

Example: fetch('url').then(res => [Link]());

You might also like