jQuery、Backbone (およびアンダースコア) およびRequireJSを使用しています。
私はこのコードを持っています:
var products = _.map(items, function(item) {
return new ProductModel({
title: item.product.title,
description: item.product.description,
link: item.product.link,
'image-src': item.product.images[0].link,
'image-height': item.product.images[0].height,
'image-width': item.product.images[0].width
});
});
残念ながら、すべてがnull. 私が意味するすべてのことなどはsitem, item.product, item.product.images, item.product.images[0]かもしれませんnull。
「合体」のようなものを探しています:
- s の処理方法を認識し、 if is
nullの例外をスローしません。item.productitemnull - があった場合、デフォルト値を指定できます
null。
そのようなものはありますか?