[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
So let's say "pizza" is some object in JS. Is
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 15
Thread images: 3
File: lejavascriptmaymay.jpg (8 KB, 300x168) Image search: [Google]
lejavascriptmaymay.jpg
8 KB, 300x168
So let's say "pizza" is some object in JS.

Is pizza.attributes a special property or something?
>>
>>51525313
what kind of toppings?
>>
>>51525950
v funny smartass

I mean is "attributes" a reserved property in Javascript if you know what I mean?
>>
File: 1397636955595.jpg (33 KB, 402x604) Image search: [Google]
1397636955595.jpg
33 KB, 402x604
>>51527526
What makes you think any of us know?
All we do is circlejerk over watches, desktops and arch.
>>
pizza.attributes is a variable or function or object or anything within pizza.

http://jsfiddle.net/9j9nvkbu/

Does this help?
>>
>>51525313
>java script
>pizza
Counting down until: >"botnet wants me to starve."
>>
File: logo-medium.png (13 KB, 262x119) Image search: [Google]
logo-medium.png
13 KB, 262x119
pizza.topptributes is a new ES8 feature that provides promises for all non-free pizza distriutors for free pizza
>>
>>51527675

Also I said attribute in the comments however the correct term is property.
>>
>>51527699
you can also call Object.keys on any object to enumerate the properties

i.e.

Object.keys(pizza)\
>>
>>51525313
do you mean like >>51527675

or do you mean something like:

var pizza = {};

pizza.toppings = [
'pepporoni',
'cheese',
'sauce'
];
>>
>>51527807

Yep. I've always been partial to doing
for (prop in object) {
object[prop](); // or anything else
}

myself.

>>51527831

To be fair, those are both the same. I add a property pizza.size that illustrates what OP is asking.
>>
>>51525950

underrated comment
>>
>>51527845
you're right. i suppose it depends on how many instances of the object you want.
>>
>>51527879

Remove the immediate object creation and you can make as many unique pizzas as you want. Unless I misunderstand what you mean.

I had forgotten how to make empty objects honestly. I can't remember the last object I made without closure of some kind. Scope safety is very important to me.
>>
>>51525313
console.log(Object.prototype.pizza);

If this logs 'undefined' to console then it isn't.
Thread replies: 15
Thread images: 3

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.