- Netflix
- Walmart
- Paypal
JS can be used for Front-end , backend or well full-stack developer. What seperates JavaScript from other languages is that it is a dynamic language.
- Web / Mobile .
- Real time Networking apps. such as chats or video
- Command line tools.
- Games.
- On browser
- On Node browser - This means that we can build the backend of our web and mobile applications with JS.
- ECMAS is a specification.
- JS is a programing language.
- Live server - lightweight web sever
console.log('Hello');
alert('yo');
typeOf name
o/p -> "string"
You don't really need to install seeing as JS can be runned on the browser but we would use nodejs to install 3rd party libraries.
After install Live Server to run the server rt-click on the .html file a click on 'start Live server'.
To use JavaScript we need to add a script element inside the .html page.
<script>
console.log('Hello');
</script>
HTML is all about "CONTENT" JS is all about "BEHAVIOUR" What this states is that you should keep ur JS in a seperate file i.e ".js" for e.g "index.js" i.e what ever is in the script tag should be in this file or files.
To run the JS file with help of Node simply do ->
$ node index.js
By default Variables in JS are intially defined as 'undefined'.
- Cannot be a reserved keyword
- Should be meaningful
- Cannot start with a number (1name)
- Cannot contain a Space or Hyphen (-)
- Are case-sensitive
- The best practice is to have each variable declared and initialised in a different line.
- Use Pascal notation while declaring variables.
const - Value remains constant use this when you what don't want the value to change or you should use 'let' seeing as 'var' causes some issues.
2 types of strings or the values that you can assign to a variable.
- Primitives / Value Types.
- String
- Number
- Boolean
- undefined
- null e.g:
let name = 'Rishabh'; // String Literal let age = 20; // Number Literal let isApproved = false; // Boolean Literal let firstName = undefined; // This is by default undefined so theirs really no need to assign 'undefined' to it. let selectedcolor = null;
- Referenced Types
- object
- Array
- Function
What seperates JavaScript from other languages is that it is a dynamic language. Their are 2 types of languages-> Static - After declaring a variable the type of the variable can't be changed Dynamic - The type can be changed at run time. Use typeOf to check the type of variable. In JS all number have a type of "number" i.e 30 and 30.0 have a type of number and not float.
'undefined' can be a value as well as type of a variable. 'null' holding variable has a type of 'object'.
let person = {
name = 'R.K',
age = 20
}
// Dot notation
person.name = 'M.K'
console.log(person.name);
Use the above when you know the name of the property.
// Bracket notation
person['name'] = 'M.K'
Use the above when you don't know the name of the property.
Objects in the array as well as the size of the array or dynamic meaning
let person = ['R.K', 'M.K'];
person[2] = 1;
console.log(person);
In JS arrays have a type 'object'. Whenever a array is declared it inherits a bunch of methods.
function greet(name, lastName) {
console.log('Hello' + name + ' ' + 'lastName');
}
let name = 'Rishabh';
let lastName = 'Kohale';