4 ms·
I have situations like this quite frequently where I need to turn vars into members of an object: title = getTheTitle() img = (shouldWeGetImg) ? getImg
by lowboy 14y ago
I have situations like this quite frequently where I need to turn vars into members of an object:
title = getTheTitle()
img = (shouldWeGetImg) ? getImg() : "placeholder.jpg"
body = ...
# 8 lines of code to define body, some that reference title and img
# this:
obj = { title, img, body }
# instead of:
obj = {title: title, body: body, img: img}