N
N
Nikolay Semenov2017-04-05 17:02:31
JavaScript
Nikolay Semenov, 2017-04-05 17:02:31

How to pass an object to a function?

Guys, hello everyone?
how to pass a parameter to this function

export const qtyInCart = state => {
    const found = state.cart.added.find( p => p.id === id)
    if (!found){
        return 0
    } else
        return found.quantity
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vlad Feninets, 2017-04-05
@fnnzzz

if it is an ES6 import, then only after the import can it be called

import { qtyInCart } from './qtyInCart.js'
qtyInCart(param)

if it's requirejs then
var qtyInCart = require("./qtyInCart.js")(param)

W
wostex, 2017-04-05
@wostex

Is it Vuex? Just add a parameter with a second number:

myMutation: (state, payload) => {...} // для mutations

myAction: (context, payload) => {...} // для actions

payload - the same parameter/object/payload

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question