what is javascipt ?
Javascript is a interpreted scripting dynamically typed object programming language.It is used to behaviour of web pages.It can calculate,manipulate and validate data.supports mutliple paradigm such as imperative,functional and object oriented. the scripting language for Web pages.
object-oriented scripting language used to make webpages interactive (e.g., having complex animations, clickable buttons, popup menus, etc.).
Interperted:
Means translate the source code to machine code.
Dynamical:
It is automatically find the what type of data in run time of execution the program.
scripting:
It is describe the line by line read the program code and execution.
object oriented:
Object-oriented (OO) is
a programming model that structures software around data, or "objects," instead of functions and logic.Objects combine data (properties) and the methods (functions) that operate on that data.
variables declaration:
there are three types:
var,let,const
Variables in JavaScript are named containers for data.
let:
Declares a block-scoped variable that can be reassigned.
let age = 30;
age = 31; // This is allowed
const:
Declares a block-scoped variable whose value cannot be reassigned after it's initialized.
const pi = 3.14;
var:
An older way to declare a variable. It is function-scoped or globally-scoped and can be redeclared and reassigned.
var count = 5;
var count = 10; // This is allowed
Rules for identifiers of varaiables:
Valid characters: Can contain letters, numbers, underscores (_), and dollar signs ($). Numbers are not allowed as the first character.
Case-sensitive: myVariable is different from myvariable.
Cannot be reserved words: You cannot use JavaScript's keywords (like if, for, function) as variable names.
Data types:
1. Number:Represents numeric values (integers and decimals).
let n = 42;
2. String: Represents text enclosed in single or double quotes.
let s = "Hello, World!";
3. Boolean: Represents a logical value (true or false).
let bool= true;
4. Undefined: A variable that has been declared but not assigned a value.
let notAssigned;
console.log(notAssigned);
Output:
undefined
5. Null: Represents an intentional absence of any value.
let empty = null;
6. Symbol: Represents unique and immutable values, often used as object keys.
let sym = Symbol('unique');
7. BigInt: Represents integers larger than Number.MAX_SAFE_INTEGER.
let bigNumber = 123456789012345678901234567890n;
Non-Primitive Datatypes
Non-primitive types are objects and can store collections of data or more complex entities.
1. Object: Represents key-value pairs.
let obj = {
name: "Amit",
age: 25
};
2. Array: Represents an ordered list of values.
let a = ["red", "green", "blue"];
3. Function: Represents reusable blocks of code.
function fun() {
console.log("GeeksforGeeks");
}
Exploring JavaScript Datatypes and Variables: Understanding Common Expressions
console.log(null === undefined)
Expression: null === undefined
Result: false
Top comments (0)