DEV Community

Vamshi Krishna
Vamshi Krishna

Posted on

JavaScript Key fundamentals Part - 1

  1. Variables: A way to store values, can be assigned and reassigned.
var name = "Vamshi"; // Global  Variable 
let age = 23; // Local Variable
const pi = 3.14; // constant 

Enter fullscreen mode Exit fullscreen mode

2.Data Types: JavaScript has 7 data types: Number, String, Boolean, Null, Undefined, Object, and Symbol.

let num = 42;
let str = "Hello World";
let bool = true;
let null= null;
let undefined;
let obj = { name: "John", age: 30 };
let sym = Symbol("unique");

Enter fullscreen mode Exit fullscreen mode

3.Operators: Used to perform operations on variables and values, such as arithmetic, assignment, comparison, and more.
Arithmetic operators: perform arithmetic operations such as addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).

let a = 10;
let b = 5;
let c = a + b;
console.log("The value of c is:", c);

Enter fullscreen mode Exit fullscreen mode

Comparison operators: compare values and return a boolean value (true or false). Examples: equal (==), not equal (!=), greater than (>), less than (<), greater than or equal to (>=), less than or equal to (<=).

let a = 10;
let b = 5;
let result = (a > b);
console.log("The result is:", result);

Enter fullscreen mode Exit fullscreen mode

Logical operators: perform logical operations such as and (&&), or (||), and not (!).

let a = true;
let b = false;
let result = (a && b);
console.log("The result is:", result);

Enter fullscreen mode Exit fullscreen mode

Assignment operators: assign values to variables. Examples: equal (=), add and assign (+=), subtract and assign (-=), multiply and assign (*=), and divide and assign (/=).

let a = 10;
a += 5;
console.log("The value of a is:", a);

Enter fullscreen mode Exit fullscreen mode

Conditional (ternary) operator: a shorthand way of writing an if-else statement.

let a = 10;
let b = 5;
let result = (a > b) ? "a is greater than b" : "a is less than or equal to b";
console.log("The result is:", result);

Enter fullscreen mode Exit fullscreen mode

SurveyJS custom survey software

Simplify data collection in your JS app with a fully integrated form management platform. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more. Integrates with any backend system, giving you full control over your data and no user limits.

Learn more

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay