• Home
  • Success Stories
  • front-end
  • data-science
  • Software Testing
  • Courses
  • Apply
  • ISA
  • Events
  • F1 Student Placement Data
  • FAQ
  • Blog
  • Resources
  • Internships and Jobs
  • Privacy Policy
  • Pay
  • Home
  • Success Stories
  • front-end
  • data-science
  • Software Testing
  • Courses
  • Apply
  • ISA
  • Events
  • F1 Student Placement Data
  • FAQ
  • Blog
  • Resources
  • Internships and Jobs
  • Privacy Policy
  • Pay
WYNISCO
  • Home
  • Success Stories
  • front-end
  • data-science
  • Software Testing
  • Courses
  • Apply
  • ISA
  • Events
  • F1 Student Placement Data
  • FAQ
  • Blog
  • Resources
  • Internships and Jobs
  • Privacy Policy
  • Pay

    Author

    This blog are ideas and learnings of Wynisco employees and bootcamp students

    Archives

    May 2022
    February 2022
    January 2022
    December 2021
    November 2021
    October 2021
    April 2021
    March 2021

    Categories

    All

    RSS Feed

Back to Blog

Basics Of JavaScript (Data Type, Variables, Function) By Arushi Gupta

2/24/2022

 
There are different types of data that we can use in a JavaScript program.
​For example,
const x = 5;
const y = "Hello";
Here,
  • 5 is an integer data.
  • "Hello" is a string data.

JavaScript Data Types

​There are eight basic data types in JavaScript. They are:
Data Types
Description
​Example
String
Represents textual data
'hello', "hello world!" etc
Number
an integer or a floating-point number
3, 3.234, 3e-2 etc.
BigInt
an integer with arbitrary precision
900719925124740999n , 1n etc.
Boolean
Any of two values: true or false
true and false
undefined
​a data type whose variable is not initialized
let a;
null
denotes a null value
let a = null;
Symbol
data type whose instances are unique and immutable
let value = Symbol('hello');
Object
key-value pairs of collection of data
let student = { };
Here, all data types except Object are primitive data types, whereas Object is non-primitive
​Note: The Object data type (non-primitive type) can store collections of data, whereas primitive data type can only store a single data.
JavaScript Variables

4 Ways to Declare a JavaScript Variable:
  • Using var
  • Using let
  • Using const
  • Using nothing

What are Variables?
​Variables are containers for storing data (storing data values).

In this example, x, y, and z, are variables, declared with the var keyword:
Example
var x = 5;
var y = 6;
var z = x + y;

In this example, x, y, and z, are variables, declared with the let keyword:
Example
let x = 5;
let y = 6;
let z = x + y;

In this example, x, y, and z, are undeclared variables:
Example
x = 5;
y = 6;
z = x + y;

From all the examples above, you can guess:
  • x stores the value 5
  • y stores the value 6
  • z stores the value 11​

When to Use JavaScript var?

  • ​Always declare JavaScript variables with var,let, orconst.
  • The var keyword is used in all JavaScript code from 1995 to 2015.
  • The let and const keywords were added to JavaScript in 2015.
  • If you want your code to run in older browser, you must use var.

When to Use JavaScript const?

  • If you want a general rule: always declare variables with const.
  • If you think the value of the variable can change, use let.


JavaScript Functions

A JavaScript function is a block of code designed to perform a particular task.A JavaScript function is executed when "something" invokes it (calls it).
​Example
function myFunction(p1, p2) {  

​return p1 * p2;   // The function returns the product of p1 and p2


​}
JavaScript Function Syntax

​
A JavaScript function is defined with the function keyword, followed by a name, followed by parentheses ().Function names can contain letters, digits, underscores, and dollar signs (same rules as variables).The parentheses may include parameter names separated by commas:(parameter1, parameter2, ...)The code to be executed, by the function, is placed inside curly brackets: {}
function name(parameter1, parameter2, parameter3) {  
​
 //
code to be executed

​}
​Function parameters are listed inside the parentheses () in the function definition. Function arguments are the values received by the function when it is invoked. Inside the function, the arguments (the parameters) behave as local variables. A Function is much the same as a Procedure or a Subroutine, in other programming languages.
0 Comments
Read More

Your comment will be posted after it is approved.


Leave a Reply.

Services

Courses
​F1 Stud App
​React 
Apply
React Syllabus
Internships
Data Analyst/Science
Software Testing/QA
​
​
​


Company

Home
ISA​
​Linkedin Group
​
Recruiters/HR
​
Contact Us
​
Blog
Resources
Certificate
Life in Wynisco
​About Us
For Employers
Privacy Policy
​

​
​



​
© COPYRIGHT 2020 ALL RIGHTS RESERVED.