JavaScript Basics:
JavaScript is a high-level, interpreted programming language that enables you to create dynamically updating content, control multimedia, animate images, and much more. It is widely used for front-end web development and increasingly for back-end development with the advent of technologies like Node.js.
Syntax::
<! DOCTYPE html>
<Html>
<Head>
<Title>JavaScript Introduction</title>
</head>
<Body>
<h2>JavaScript Introduction Example</h2>
<p>Click the button to change the text in this paragraph.</p>
<button onclick=”change Text ()”>Click me</button>
<p id=”demo”>This is some text. </p>
<Script>
function changeText () {
document.getElementById (“demo”).innerHTML = “Text changed!”;
}
</script>
</body>
</html>
DataTypes:
Number: Represents numeric data, including integers and floating-point numbers.
let num1 = 42;
let num2 = 3.14;
String: Represents textual data, enclosed in single or double quotes.
Get Iram Shahzadi’s stories in your inbox
Join Medium for free to get updates from this writer.
let str1 = ‘Hello, world!’;
let str2 = “JavaScript is awesome!”;
Boolean: Represents a logical entity and can have two values: true or false.
let isRaining = true;
let isSunny = false;
Undefined: Represents a variable that has been declared but not assigned a value.
let x;
console.log(x); // will output: undefined
Null: Represents an intentional absence of any object value.
let y = null;
Object: Represents a collection of key-value pairs.
let person = {
name: ‘John Doe’,
age: 30,
profession: ‘Developer’
};
Array: Represents a collection of elements, which can be of any data type.
let numbers = [1, 2, 3, 4, 5];
let fruits = [‘apple’, ‘banana’, ‘cherry’];
Function: Represents a block of code that can be invoked.
function add(a, b) {
return a + b;
}
Symbol: Represents a unique identifier.
const key = Symbol(‘description’);









