JavaScript
  • JavaScript Introduction
  • JS Engine
  • V8 Engine
  • First-class function
  • Optimized Code
  • Call Stack & Memory heap
  • Single Thread
  • JavaScript RunTime
  • Nodejs
  • Context and Environment
  • Hoisting
  • Functions
  • Arguments
  • Variables
  • Scope
  • IIFE
  • this
  • call(), apply() and bind()
  • currying
  • Types
  • Type Coercion
  • Functions as Object
  • HOF (Higher Order Function)
  • Two pillars of Javascript
  • Closures
  • Prototypal Inheritance
  • OOP and FP
  • OOP
    • 4 principles of OOP
  • FP
    • Pure function
    • Imperative vs Declarative
    • Immutability
    • HOF and Closures
    • Currying
    • Partial Application
    • Compose and Pipe
  • Composition vs Inheritance
  • OOP vs FP
  • JS working
  • Promises
  • Async Await
  • ES5 - ECMAScript 2009
  • ES6 - ECMAScript 2015
  • ES7 - ECMAScript 2016
  • ES8 - ECMAScript 2017
  • ES9 - ECMAScript 2018
  • ES10 - ECMAScript 2019
  • ES11 - ECMAScript 2020
  • ES12 - ECMAScript 2021
  • JOB Queue
  • Promises Execution
Powered by GitBook
On this page

Was this helpful?

Arguments

An argument is an object created inside execution context of the function when it is invoked.

  • Created when the function is invoked.

  • arguments are the input parameters passed to the function.

  • It is an object that contains the index of the parameters as key and parameters are assigned as values against its index key.

  • arguments values are accessed with arguments key word.

  • arguments is not suggested to be used in the optimized codes instead use spread.

EX 1:
function greet() {
    console.log(arguments);
}
greet(); // {}

EX 2:
function greetME(name) {
    console.log(arguments);
}
greetME("Vijay"); // { 0: "Vijay" }

EX 3: // using spread to access arguments as array
function greetings(...args) {
    console.log(args);
}
greetings("Hello", "Vijay") // ["Hello", "Vijay"]
PreviousFunctionsNextVariables

Last updated 5 years ago

Was this helpful?