Java script is scripting language as well as programming language. Using HTML and css we build static web pages. To bring static web page as dynamic js is used. Example we have p tag in html when we hit the button the paragraph content need to change means we us js it dynamically changes the content during run time.
Features of Javascript:
*It is mainly used for client side scripting language.
Client sends request to server with file name. Server sends response as a static web page with file name. Inside static web page we have written js code in the script that converts static web page as dynamic and displays in the browser.
It is interpreted programming language. V8 engine is available in browser it is also called as js engine. It reads source code line by line from the high level language to converts machine code and displays output in high level language(English content as per our understanding). It happens in client side.
If we want to run the js in server side node js runtime environment is there for running.JS is dynamically typed and weekly typed programming language.
Statically typed programming language means it checks variable data type during compile time. We have to provide datatype for the variable during declaration itself.
Dynamically typed programming language means we no need to provide datatype during var declaration. It checks var datatype during run time. It automatically takes var datatype.JS is Asynchronous programming language.
Synchronous means the program has to wait for task 1 completion then task 2 will start executes.
Asynchronous means during execution of task 1 suppose it takes long time for execution task 2 also will start execution. Task 1 will not block task 2 execution.Event driven programming language - When the user clicks enter button without providing the required field in the form, it will throw the pop up message. This validation is done by js.
it is used to provide single page application- Client send request server send response now if we want to just modify particular template or component of web page that page only reloads not entire web page. For example when we hit like for one facebook post, not the entire web page loads just loading that component. For multiple page application for each hit the entire new web page loads again and again from server. Like sending request to server and getting response.
JS is not full fledged programming language. It is object based scripting language.
Datatypes of Javascript:
JavaScript has 8 Datatypes
String
Number
Bigint
Boolean
Undefined
Null
Symbol
Object
The Object Datatype
The object data type can contain both built-in objects, and user defined objects:
Built-in object types can be:
objects, arrays, dates, maps, sets, intarrays, floatarrays, promises, and more.
String:
No char in JS. Everything is considered as String.
In js, we use single quotes, double quotes or backtick`` to represent string.
Primitive data type:
number String null undefined boolean
It has fixed memory size.
Non primitive data type: also called as reference type
object array
it has dynamic memory allocation
Array: collection of similar elements. It is accessed through index. Index starts from 0.
let carmodel=[“Tata”,”Hyundai”,”Honda”]
console.log(carmodel);
console.log(carmodel[0]);
Object: it is a combination of state and behavior. Real world entity.
It is a key value pair.
let vehicle={
vehicletype :”car”,
wheels: 4
price:50000
}
console.log(vehicle);
console.log(vehicle.price);
Top comments (0)