Cheatography
                https://cheatography.com
            
        
        
    
                   
                            
    
                    JavaScript - Basics Concepts
                    
                 
                    
        
        
            
    
        
                            
        
                
        
            
                                
            
                
                                                | Variables
                        
                                                                                    
                                                                                            |  | block scope | most used |  
                                                                                            |  | constant values |  
                                                                                            |  | global or function scope | old usage |  Operators
                        
                                                                                    
                                                                                            |  | assignment |  
                                                                                            |  | comparison |  
                                                                                            |  | strict comparison |  
                                                                                            |  | logical AND |  
                                                                                            |  | logical OR |  
                                                                                            |  | logical negation |  Data Types
                        
                                                                                    
                                                                                            |  | Number |  
                                                                                            |  | String |  
                                                                                            |  | Boolean |  
                                                                                            |  | Array |  
                                                                                            | let obj = { a:1, b:2, c:"three" }
 | Object |  Array
                        
                                                                                    
                                                                                            | let array = ["a","b","c"]
 | array definition |  
                                                                                            |  | number of elements in array |  
                                                                                            |  | access first element |  
                                                                                            | array[n] //0=<n<array.length
 | access nth element |  
                                                                                            |  | 4 grater then length of array |  
                                                                                            | array[array.length - 1] // c
 | access last element |  Comments
                        
                                                                                    
                                                                                            | // this is a one line comment
 |  
                                                                                            | /* this is a multiple lines comment
 also called block comment */
 |  |  | Object
                        
                                    
                        | let object = {
   name: "Alice",
   age: 30
}
 |  Unlike JSON, a JavaScript object does not have double quotes (") in the property name Object usage
                        
                                                                                    
                                                                                            |  | dot notation |  
                                                                                            |  | property access notation |  
                                                                                            |  |  
                                                                                            | object.gender // undefined
 | non-existent property |  try...catch...finally
                        
                                    
                        | try{
   //code might throw an error
} catch(err) {
   console.error("Error occurred", err.message);
} finally {
   console.log("Operation completed");
}
 |  try: This block contains code that might throw an exception (an error)catch: This block handles the exception if an error occurs in the try block
 finally: This block always executes, regardless of whether an error occurs or not
 Function
                        
                                    
                        | function greet() {
   console.log("Hello")
}
 |  Function with parameter
                        
                                    
                        | function greet(name="Alice") {
   console.log("Hello")
}
 |  parameter name with default value "Alice" | 
            
                            
            
            
        
        
        
        
        
            
    
        
          
Created By
https://www.techelopment.it
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by techelopment