📒
Notes
Cloud ComputingData Science/AIGame Development
  • Home
  • Big O
  • Data Structures & Algorithms
    • Data Structures
      • Array
      • Stack
      • Queue
      • Linked List
      • Binary Tree
    • Algorithms
      • Searching
      • Sorting
      • Graphs
        • Searching
        • Minimum Spanning Tree
        • Shortest Path Algorithms
      • String Algorithms
  • Object Oriented Programming
  • Languages
    • HTML/CSS
      • CSS
    • C++
    • C#
      • Types
      • Keywords
        • Modifiers
          • Access Modifiers
        • Method Parameters
      • Operators and Expressions
      • Collections
      • Constructors
      • Delegates
      • Indexers
      • Concepts
      • Features
        • LINQ
          • Operators
          • Working with Data
          • Methods
          • Resources
        • Asynchronous Programming
        • Reflection
    • Dart
    • GraphQL
    • JavaScript
      • Variable and Parameter
      • Built-in objects
        • Array
        • Built-in Functions
      • Functions
      • Classes
      • Prototype
      • Libraries
        • jQuery
        • React
          • Components
          • State and Lifecycle
          • Hooks
            • useState
            • useEffect
          • Resources
      • Testing Framework
      • Web APIs
    • Kotlin
      • Basics
    • Python
      • Basics
      • Data Structures
      • Functions
      • Resources
        • Flask
    • SQL
      • Basics
      • Operators
      • JOINs
      • Aggregations
      • Subqueries
      • Views
      • Functions
        • Window Functions
      • Stored Procedures
      • Performance Tuning
      • Extras
    • Resources
  • 🌐Web Frameworks
    • Angular
      • Templates
      • Directives
        • Attribute Directives
        • Structural Directives
    • ASP.NET
      • Fundamentals
        • Dependency Injection
        • Middleware
        • Session & State Management
      • Web apps
        • MVC
          • Controllers
            • Filters
          • Models
            • Model Binding
            • Model Validation
          • Views
            • Tag Helpers
            • View Components
          • Features
        • Client-side development
      • Web APIs
        • Controller-based APIs
        • Minimal APIs
        • OpenAPI
        • Content Negotiation
      • SignalR
      • Host and Deploy
        • IIS
      • Security
    • Django
      • The Request/Response Cycle
    • Terminologies
      • Web Server
        • Internet Information Services
    • Resources
  • 📱App Frameworks
    • Introduction
      • Resources
    • Xamarin
      • Lifecycle
      • Custom Renderers & Effects
      • Behaviors
      • Triggers
      • Gestures
      • Commands
      • Dependency Service in XF
      • Libraries
      • Showcase
    • .NET MAUI
      • Controls
      • Navigation
      • Storage Options
  • Multi-Platform Frameworks
    • .NET
      • .NET Framework
        • ADO.NET
        • WCF
      • Fundamentals
        • Logging
        • Testing
      • Advanced
        • Asynchronous Programming
        • Parallel Programming
        • Threading
        • Memory Management
          • Garbage Collection
    • Flutter
  • Object-Relational Mappers
    • Entity Framework
      • Application Models
      • Configuration
      • Setting Up
      • Advanced
  • Databases
    • Introduction
      • DBMS Architecture
      • Normalization
      • Database Transaction Models
    • Relational Databases
      • Microsoft SQL Server
        • Basics
        • Functions
        • Stored Procedures
        • Error Handling
        • Log Shipping
        • Querying and Manipulating JSON data
        • Statements
        • Topics
        • Extras
    • Non-Relational Databases
      • MongoDB
      • Redis
        • Data Structures
        • Introduction
        • Managing Database
  • Tools
    • Version Control
      • Git
        • Setup and Config
        • Basics
          • Sharing and Updating Projects
        • Resources
      • Perforce Helix
    • GitHub
    • Powershell
  • Software Development
    • Software Development Life Cycle
    • Software Design Patterns
      • GoF Design Patterns
      • Architectural Patterns
        • MVC
        • MVVM
        • N-tier Architecture
        • Onion Architecture
        • Data Transfer Objects
      • CQRS
    • Software Design Principles
      • S.O.L.I.D. Priniciple
  • System Design
    • Topics
      • Load Balancing
  • Topics
    • JWT
    • Caching
      • Static vs Dynamic Caching
    • OSI model
      • HTTP
    • Glossary
    • API
      • SOAP
      • REST
    • Microservices
    • WebHooks
    • Practice
    • Operating Systems
      • Windows
    • Architecture
  • 🔖Bookmarks
  • 🔗Resources
Powered by GitBook
On this page
  • Arrow Functions
  • Immediately Invoked Function Expression (IIFE)
  • Async Functions
  • Shared Array Buffers & Atomics

Was this helpful?

  1. Languages
  2. JavaScript

Functions

let greeting = function(){
    return 'Hello, World!';
}

let message = greeting();
console.log(message);            //Hello, World!
let greeting = function greet(name){
    return 'Hello, ' + name;
}

let message = greeting('World!');
console.log(message);                //Hello, World!

Arrow Functions

  • a.k.a. Anonymous functions, or Lambda functions.

  • Introduced in ES6.

  • Arrow functions do not have their own this value.

let greeting = () => { 
    return 'Hello, World!'; 
}

let message = greeting();
console.log(message);        // Hello, World!
let greeting = (name) => 'Welcome ' + name + ' to the World of JavaScript!';

let message = greeting('Jerry');
console.log(message);        // Welcome Jerry to the World of JavaScript!
let msg = {
    name: "John",
    regularFunction: function(){
        console.log('Hello, ' + this.name);
    },
    arrowFunction: () => console.log('Hi ' + this.name)
}

msg.regularFunction();        //Hello, John
msg.arrowFunction();          //Hi

Here in this example, when we call this.name from msg.arrowFunction(), it looks for the name variable in the global context and cannot find it. Therefore only Hi gets printed. if we try to print this.name it will return an empty string.

Generators

  • a Generator function is a function that generates iterator.

Immediately Invoked Function Expression (IIFE)

  • a.k.a. a Self-Executing Anonymous Function.

  • a JavaScript function that runs as soon as it is defined.

  • let us group our code and works in isolation, independent of any other code.

(function(){                                // IIFE
    console.log('Hello, World!');
})();

(() => {                                    // Arrow Function IIFE
    console.log('Hello, World!');
})();

(async () => {                              // async IIFE
    console.log('Hello, World!');
})();

this keyword refers to the owner of the function we are executing.

Async Functions

Promise

  • When resolved it makes the result available

  • States: Pending, Fulfilled, Rejected

  • Promise.all - takes multiple promises and returns a promise which resolves when all supplied promises are done.

  • Promise.race - is the same as Promise.all but it resolves when first promise is done.

Shared Array Buffers & Atomics

  • An ArrayBuffer instance represents a piece of memory: binary data

  • Typed arrays are needed to access data in an ArrayBuffer

  • The SharedArrayBuffer is an ArrayBuffer for which underlying data can be shared across threads

  • Atomics global variable provides a collection of tools to work with the SharedArrayBuffer

PreviousBuilt-in FunctionsNextClasses

Last updated 3 years ago

Was this helpful?