javascriptecmascript-6lodashjsbin

How to make lodash import in JSBin?


I need to show one code in JSBin with the lodash and cannot figure it out how to make a 'get' import. I've got "ReferenceError: require is not defined https://jsbin.com/hotobir/edit?js,console

// Normally that is working fine
import { get } from 'lodash'

//No import get from 'lodash/get'
//No const { get } = lodash

const obj = { myKey: 'myValue' }
console.log(get(obj, 'myKey', 'notThere'))

How to do this import?


Solution

  • By default, the JSBin drop the script import in the wrong place. It shoul to be in the head of html.

    const {get} = _
    const obj = { myKey: 'myValue' }
    console.log(get(obj, 'myKey', 'notThere'))