« first day (426 days earlier)      last day (4747 days later) » 

03:00
“best result achieved by any JS implementation is still more than an order-of-magnitude slower than native code“ @jgw http://blog.j15r.com/2011/12/for-those-unfamiliar-with-it-box2d-is.html
RT @w3c: W3C Invites Implementations of Touch Events version 1 http://ow.ly/1gcx5f
RT @w3c: First Drafts of Three Audio API Specifications Published http://ow.ly/1gcx5b
var foo = new function(){

this.bar = "a";

this.baz = "ab";

};
i actually find that more readable than
var foo = {

bar : "a",

baz : "aaaaa"

};
you are probably in the very small minority then
and obviously, it's more flexible as far as what you can do inside of it
or perhaps completely alone
probably so
03:02
object literal couldn't be more sugary
wouldn't be the first time
though I put the colons right after keys
as in
well yeah
var foo = {
    bar: "a",
    baz: "aaaaa"
};
that was kind of copypasted
from the one above
how are you doing that, the markdown way?
03:04
ctrl+k
ah
yeah it's very much a preference thing and nobody else i've come across seems to prefer it, so i only use it in personal stuff, but i've been using it for a long time and strogly prefer it. it's weird
I mean if you remove the semicolon, curlybraces and var, even my grandma could probably see what it does :D
yeah but what if you want to create baz programatically given that you know bar
var foo = new function(){
  this.bar = "a";
  this.baz = this.bar + this.bar + this.bar + this.bar;
};
or whatever
You are probably looking at a class then and not an object literal
well what if baz and bar are functions
03:08
if it's just derived value from a static value you just put the derived value
and for whatever reason they share the same function reference is some case
var foo = {
    bar: function(){

    },
    baz: function(){
    	return this.bar();
    }
};
i'm just saying, you can actually do stuff inside of the declaration, which comes in handy
yeah, sure, with call, and arguments, etc
if you need to do real dynamic stuff you are looking at a class with initialization logic, not an object literal
I think new function() {} is an anti pattern aswell
03:11
Raynos, jslint agrees with you
are you referring to a singleton
you can only ever get a one instance with new function(){} which is a singleton which is an antipattern imo :P
in a way. It is an anonymous constructor function which is only intended to be called once (usually)
singleton is not an antipattern
imo
but not sure this is singleton
in fact no this is def not singleton
how so
you will end up with one instance of a class that cannot create other instances ever
well you will end up with one object
but it doesn't really do singleton stuff
it's a prototype object so many copies of it get made
i mean i guess it's similar to singleton but not really the same
you cannot create any other instances because the constructor to make them is lost right after executing that line
03:15
right but it is the prototype so every instance of the class references it
whereas a singleton would usually just do it's own thing and other stuff would tell it what to do
using "class" loosely of course, you know what i mean
var a = new function Person(){this.sayHello = function(){};} how to create another instance of that Person? You can't. and of course by class I don't mean a classical class :P
no no
it's not new funtion person
just new function
it's anonymous
doesn't really matter if its anonymous, it won't be available cos it's a function expression
right
well look at it this way
but when you console log a
it will say it's a Person
03:17
the two examples from earlier
...
produce the same object
in different ways...
neither one is a 'singleton', they're just objects
@user886931 and a singleton is an object :)
Well yes
so it's a singleton just like every object created with the literal syntax is a singleton
03:20
you can create multiple instances of Object
i am agreeing with you
var a = {}, b = {} ...
no you're missing the point
var foo = new function(){
this.bar = "a";
this.baz = "ab";
};

var foo = {
bar : "a",
baz : "ab"
};
those two expressions produce pretty much identical objects
are the objects they produce singletons?
seems foo.__proto__ is Object so it's an instance of Object
in both cases right
03:23
should you give the function any name at all that's not the case then
var foo = new function f(){
this.bar = "a";
this.baz = "ab";
};
no
it will fuck ie up
in that case foo.__proto__ is not Object
how so
var foo = function f(){} will fuck IE up
i don't remember the details, it does something stupid like create two copies of the function
and it's probably ie < 9
but you're not supposed to do it
@user886931 Nope.
seems that it does so for even (function f(){})
03:25
@Esailija singletones are not about how an object is created but more how it's used. it's a programming pattern.
Code Complete 2nd Edition:
> Singleton :Provides global access to a class that has one and only one instance.
var a = new function Person(){this.sayHello = function(){};} that will be a singleton in all browsers except IE<9
no stop that
that's just confusint
t/g/
lol
but it's true.. only IE leaks the Person so it can be instantiated again
03:27
don't say it will be a singleton
WHAT EVEN IS THIS
@Esailija y u troll
singleton is not about how you create it. but how you use it. it's a designing pattern not object type.
In software engineering, the singleton pattern is a design pattern used to implement the mathematical concept of a singleton, by restricting the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. The concept is sometimes generalized to systems that operate more efficiently when only one object exists, or that restrict the instantiation to a certain number of objects. There is criticism to the use of the singleton pattern, as some consider it an anti-pattern, judging that it is overused, introduces unnecessary re...
Go learn what a singleton is
ahhh there it is
the rage is back
and all is well
I don't see how you can instantiate it again, and a holds the single instance
03:29
@Esailija Look, An Class can be instantiate as many time as you like.
I have a for loop
and absolutely no javascript works after the loop
and an object can be rewrite as many time as you like.
@OmeidHerat ... you cannot instantiate Person but just once.
only alerts
any reason this is happening?
i'm making an array from a get variable with php and writing it to a javascript variable
@Esailija Because.
03:31
and then i'm iterating through the array to create table rows with every 3 values in the array as separate td's
anything that comes after the for loop (or even inside it, besides writing the tr) works except alerts
the "class" is "declared" inline and then instantiated and the constructor is lost forever so you cannot create any more instances of it, yet you have a single instance of that class. That is not singleton?
THERE IS NO CLASS IN MY JAVASCRIPT
RT @Scirra: Why you really should avoid using MP3 in your HTML5 games http://www.scirra.com/blog/64/why-you-shouldnt-use-mp3-in-your-html5-games #html5 #gamedev #mp3
so does anyone know what's going on?
03:34
@Esailija a singleton is all about enforcing the existence of a single class. The pattern your describing is an instance of an anonymous class, also called an anonymous object
note all object literals in javascript are "anonymous objects"
How is it anonymous
log it in console
troll
var a = new function Person(){this.sayHello = function(){};}
a;

Person
sayHello: function (){}
__proto__: Person
if you leave the Person out it will just create a new Object which I said is not a singleton (obviously)
does anyone have an idea?
but if you name it like that it will create an instanceof Person though you can't check it because Person doesn't exist anymore after the line
03:37
hi @esailija
@esailija but you should not mix function expression and function declaration
because ie will mess it up
yes as I said, in IE it won't be a singleton because Person is leaked :P
forget singleton
@Esailija it is anonymous
it just happened to be a name anonymous function
@Raynos what?
03:41
lol
    var a = new function Person(){this.sayHello = function(){console.log(this.constructor.name);};}
a.sayHello();

//"Person"
yeah
but Person is an anonymous function, it just has a name
read that esailija :)
define anynymous then because all the signs of a named function are there
read the article... it's confusing to think of them as both named and anonymous
03:44
I have read that article
anonymous means there is no way to access it after the expression
(function named() { }());
There is no token which has the value named
anonymous is all about there is no variable containing the value that is the function
whether the anonymous function has a function name is irrelevant
but there is many ways to access it
the fact that ie8 leaks the anonymous function into a global variable is irrelevant
since the name is known inside the function
@Esailija no there is not, the only thin you can do is leak the function reference into other variables
anyway you so troll
03:46
just because the function isn't accessible in global doesn't make it anonymous? or does it ?
I give you that you can't access it in global but that's it
if you make function declarations inside function, then by that definition of anonymous they would be anonymous
Singletons Anonymous
{
  // imagine there is scope
  (function named() { ... }());
  named; // reference error
  named2; // named2 is a valid scoped token

  function named2() {

  }
}
Stop using the word singleton
there are no singletons in javascript
just like there is no private in javascript
no Singletons Anonymous is my new support group
and there are no classes either
just because I use the word class or singleton doesn't mean I imply that js is now a classical language or something
03:50
I know
I said it many times before I don't mean a classical class
but the term "singleton" has no sensible meaning
sometimes its a good idea to name anonymous functions, but not every time ...
well to be fair your use of anonymous is a bit unique
the word "class" has a sensible meaning which is a object who is the value of another objects [[Prototype]]
@ThomasBlobaum every function should be named
anonymous does not mean no-name
03:51
i've never seen named functions referred to as anonymous, anyway
anonymous means no token in scope for that function
hmm where could i find that definition?
is that a js thing?
Nowhere.
    var a = new function Person(){
//Scope where Person is known
console.log(Person);
//It's just as named as named2 in your example
}
I don't like the term "token"
@Esailija that's an internal reference :\
03:52
how can you not like tokens
Of course you can access every function internally within the function
tokens awe awesome
its not always necessary
@Raynos that's because specs mandate that an identifier should not be available to an enclosing scope:
Aha
03:53
you are never going to access it by that name so it just seems trivial
identifier, that's a good term. One should a say that a function is anonymous if there is no identifier for said function within the scope that contains the function express
Whatever, I took it from the article :D
Yes now we have a definition where Person is anonymous, good \o/ :P
but seeing as the word anonymous means ... without name or something, it's not a very good description =)
so forgive my noobness? :P
I say anonymous means without identifier
The name of the function is just meta data
its just a property of the function object
so by that logic a function could actually go from not being anonymous, to being anonymous, to not being anonymous, without its name changing
yes
03:59
it's all so confusing... it's also 6 am and I have work tomorrow
\o/
its a strange use of anonymous
@Esailija you mean work today
technically yes :D
but I just can't go directly to sleep after such an active discussion
.(
sleep noa
I n3d sleep
4am for you?
04:02
to be honest I might be wrong about my definition of anonymou
hey you can define it however you want ;)
we are all just noobs here :D
raynos i think what you were going for was function expression
maybe
Prototype-based singleton

In a prototype-based programming language, where objects but not classes are used, a "singleton" simply refers to an object without copies or that is not used as the prototype for any other object
"that is not used as the prototype for any other object"
but good catch on the objects vs "classes" thing
04:06
as in exists an object X, where X.__proto__ is an object that no other object .__proto__ refers to
or something like that
where no object.__ptoto__ refers to x
they even have drawbacks section
This pattern makes unit testing far more difficult,[6] as it introduces global state into an application.
yeah but clearly our original examples aren't this as we wre talking about building prototypes for constructors
doesn't really matter.. the original discussion started from using object literals vs new function :P
@user886931 function expression and function declarations are the only mechanism for functions
04:14
@Raynos where does new Function fall to
its most likely an express
new function () { } is an expression
Function is a factory function
@Raynos unless you consider NFE to be another
No
they are the same as FE
Except they are named
right
not anonymous ;)
that's why i thought maybe you meant FE by anonymous
although he was using a NFE so i guess that doesn't make sense
i guess "out of scope" is probably the way to describe it
NFE and FE are both anonymous in the sense that there is no identifier available in the scope where they are expressed
04:24
not true with NFE
i mean, at least within the fn itself
yes its available within the fn itself
same for FE
arguments.callee
but not in the scope where it was expressed
i thought arguments.callee was deprecated
it is.
Just saying you dont need a name to reference a function internally
04:26
no, if you don't mind deprecated arguments.callee
night
 
2 hours later…
06:25
”MediaKeys“ API proposal to enable a “secure key delivery & content decryption“ in HTML5 video & audio for DRM purposes http://www.w3.org/2011/webtv/wiki/MPTF/Netflix_Content_Protection
 
1 hour later…
07:34
can we pass arrays using jquery load command
07:55
@Sibu ?
@island205, hey, how does one get a value out of jquery?
e.g. I use var i = $(abc).children.length;
@Kayote for what?
now 'i' would be jquery(4)
*4 is arbitrary value
so I can use it in normal js
Im thinking I should just use ChildNodes & if statement to remove the 'txt' nodes (whitespaces)
from the childNodes
@Kayote code please
but I would still love to find out how to take out a value from jquery & use in normal js
ok sure, one sec
sorry you cannot run it as yet
its still incomplete
the problem is with the for loop
and I think the variable 'eChildrenNo' is the reason why its not running
08:09
@Kayote i don't know what you want TODO?
:), I want to run the 'for' loop
but it stops there and doesnt go further because of the jquery 'eChildrenNo'
08:26
@island205 this is how i am loading page
$('#menu_div2').load('ajax/div_openreviewpages.php?error=<?=$error?>')
where $error is an array
but it is not working
@Sibu $GET("error") is "<?=$error?>",what you want to get?
@island205 what??
@island205 $error is an array, which contains string message
so i was thinking can we pass strings through above method???
@Sibu where is message from?
@island205 the string has stored values
sorry i mean the array has stored values
n i need to pass it to another page
@Sibu ok.the message is going to "ajax/div_openreviewpages.php" with named error
08:36
$error[]="invalid username";
what wrong with you?
$error[]="invalid password";
like this.
but somehow it is not passing values
$('#menu_div2').load('ajax/div_openreviewpages.php?error=invalid password') like this?
@island205 no i want to pass the variable array $error, which conatins all these messages
you'll need to pass them as a url-esque array: ?error[]=err1&error[]=err2 so on
08:38
@Sibu so you can't show them in #memu_div2?
you might find http_build_query useful
@island205 i can't get the values on another page
2
Q: Which is better, minified or obfuscated code?

jazzQueryI’m confused between the two. Which is better, especially for jQuery and JS? Also, which do you think is more SEO-friendly? Note: I’m a noob. Please be kind. =) Thank you.

@Sibu $('#menu_div2').load('ajax/div_openreviewpages.php?error=<?=$error[0]?>&error=<?‌​=$error[1]?>')
that wont work island
the second one will override the first
08:42
no
@Corbin that work fine
it shouldnt
have you actually tested that?
the second error will override the first
$_GET['error'] will then be 'error2'
you can test use chrome
with error1 lost
it's a valid url; that's not my point
it won't properly populate $_GET['error']
"you'll need to pass them as a url-esque array: ?error[]=err1&error[]=err2 so on"
an array
with two element.... one being err1, the other being err2
that would make $_GET['error']
http_build_query can be used to make urls that like in an easy manner: $url = '?' . http_build_query('error' => array('err1', 'err2')); yields my example url
08:46
@Corbin i tried http_build_query i checked on mozilla
Error: unterminated string literal
@Sibu as a PHP syntax error or JS syntax error?
RT @doublec: Some recent enhancements for HTML video and audio in Firefox http://bit.ly/w1lzul
$('#menu_div2').load("ajax/div_openreviewpages.php?&rerror=<br />
guessing JS
yeah that's a PHP error
what's the code you used? PHP wise
08:48
$('#menu_div2').load("ajax/div_openreviewpages.php?error=<?php echo http_build_query($errors);?>");
this is what i did
try $('#menu_div2').load("ajax/div_openreviewpages.php?<?php echo http_build_query(array('error' => $errors));?>");
and for array i don't know how many values it contains
how to get it on another page??
what do you mean? how to access the errors now?
$_GET['error'] will be an array
$errors = (isset($_GET['error']) && is_array($_GET['error'])) ? $_GET['error'] : array();
@Corbin same error Error: unterminated string literal
$("#menu_div2").load('ajax/div_openreviewpages.php?<br />
hmmm can you paste a larger section of the code to a pastebin-type website?
09:01
@Corbin thanks for the code, it worked for me
i made some stupid mistakes...thanks
 
5 hours later…
14:02
@Raynos @rlemon upvote this plx news.ycombinator.com/item?id=3360679
:D
> This Week's JavaScript Weekly News - Issue 57
@Incognito
@ThomasBlobaum
14:55
I have this feeling that I should have been more involved in the server side code at work.
I'm not sure our server-side dev is aware of what a "constructor" is -_-
Good morning all!
:-)
Already entered :-)
I just entered Win a Paid GitHub Account for Life (worth $8,000!!)! http://appsumo.com/~aVnU via @appsumo

« first day (426 days earlier)      last day (4747 days later) »