Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chaining javascript functions. What's the order of execution?

Tags:

javascript

aka if I have a function var nameNorm= name.substring(1).toLowerCase();

what would the order be? would it turn everything lowercase then extract a substring or would it extract a substring and then turn the substring lowercase?

like image 475
user3813774 Avatar asked Jul 13 '14 03:07

user3813774


People also ask

What is chaining in JavaScript?

Method Chaining is a programming strategy that simplifies and embellishes your code. It is a mechanism of calling a method on another method of the same object. this keyword in JavaScript refers to the current object in which it is called.

What is chaining in node JS?

Promise chaining: Promise chaining is a syntax that allows you to chain together multiple asynchronous tasks in a specific order. This is great for complex code where one asynchronous task needs to be performed after the completion of a different asynchronous task.

What is chaining in programming?

Introduction. Method chaining is a programmatic style of invoking multiple method calls sequentially with each call performing an action on the same object and returning it. It eliminates the cognitive burden of naming variables at each intermediate step.


1 Answers

The . operator associates left-to-right.

so you would do the substring first, then the lower case.

like image 183
Scott Sauyet Avatar answered Oct 26 '22 17:10

Scott Sauyet