- Lodash Tutorial
- Lodash - Home
- Lodash - Overview
- Lodash - Environment Setup
- Lodash - Array
- Lodash - Collection
- Lodash - Date
- Lodash - Function
- Lodash - Lang
- Lodash - Math
- Lodash - Number
- Lodash - Object
- Lodash - Seq
- Lodash - String
- Lodash - Util
- Lodash - Properties
- Lodash - Methods
- Lodash Useful Resources
- Lodash - Quick Guide
- Lodash - Useful Resources
- Lodash - Discussion
Lodash - runInContext method
Syntax
_.runInContext([context=root])
Create a new pristine lodash function using the context object.
Arguments
[context=root] (Object) − The context object.
Output
(Function) − Returns a new lodash function.
Example
var _ = require('lodash'); _.mixin({ 'foo': _.constant('foo') }); var lodash = _.runInContext(); lodash.mixin({ 'bar': lodash.constant('bar') }); console.log(_.isFunction(_.foo)); console.log(_.isFunction(_.bar)); console.log(lodash.isFunction(lodash.foo)); console.log(lodash.isFunction(lodash.bar));
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
true false false true
lodash_util.htm
Advertisements