JSFiddle - React, Tailwind, and code Playground
by dirtyd77
HTML
<div>Please check your console (F12)</div>
JavaScript
//company
function Company(name, subsidiary) {
var self = this;
self.name = name;
self.subsidiary = subsidiary;
};
//subsidiary
function Subsidiary(name, type) {
var self = this;
self.information = {
name: name,
type: type,
type2: type
};
}
//new company
var company = new Company(
'Company 1', [
new Subsidiary('Subsidiary 1', 'small')
]),
subsid = company.subsidiary[0], //get first subsidiary
info = subsid.information, //get information
type = info.type; //get type
//does not work
type =
type === 'small' ?
'large' :
'small';
//works
info.type2 =
info.type2 === 'small' ?
'large' :
'small';
//notice type2 has changed, but type did not
console.log(company);