Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
NOP (code)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== JavaScript === The [[JavaScript]] language does not have a built-in NOP statement. Many implementations are possible: * Use the <code>;</code> ''empty statement''<ref>MDN JavaScript reference β [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/Empty empty statement]. "The empty statement is a semicolon (<code>;</code>) indicating that no statement will be executed, even if JavaScript syntax requires one."</ref> or the <code>{}</code> empty ''block statement'' the same way as in the [[NOP (code)#C_and_derivatives|C and derivatives]] examples; * Use the <code>undefined</code> or the <code>null</code> expression as a complete statement (an ''expression statement'') when the previous methods are not allowed by the syntax. Alternatives, in situations where a function is required, are: * Use the <code>Function.prototype()</code> built-in function, that accepts any arguments and returns <code>undefined</code>;<ref>ECMAScript Language Specification β Edition 5.1 β [https://www.ecma-international.org/ecma-262/5.1/#sec-15.3.4 Properties of the Function Prototype Object]</ref> * Use a NOP function available in a third-party library βsee below; * Define a custom NOP function, as in the following example (using the [[ES6]] arrow function syntax): <syntaxhighlight lang="javascript">const noop = () => {};</syntaxhighlight> ==== AngularJS ==== The [[AngularJS]] framework provides [https://docs.angularjs.org/api/ng/function/angular.noop angular.noop] function that performs no operations. ==== jQuery ==== The [[jQuery]] library provides a function <code>jQuery.noop()</code>, which does nothing.<ref>[http://api.jquery.com/jquery.noop/ jQuery.noop()] from jQuery API documentation</ref> ==== Lodash ==== The [[Lodash]] library provides a function <code>_.noop()</code>, which returns undefined and does nothing.<ref>{{Cite web|url=https://lodash.com/docs/#noop|title=Lodash Documentation|website=lodash.com|language=en|access-date=2017-12-15}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)