Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » JavaScript: Enough BS

This thread is locked; no one can reply to it. rss feed Print
 1   2 
JavaScript: Enough BS
Billybob
Member #3,136
January 2003

I'm wasting gobs of time struggling with JavaScript. Is there anyway to have JavaScript tell me all the attributes of a given object? In particular, I need to know what stuff the event object has, because I seriously can't figure out what it does and doesn't have in Firefox.

Or a decent online documenation of what these objects have and don't have under various browsers. w3schools lists some things, but it sucks when it comes to telling me what each browser does and doesn't have.

Marcello
Member #1,860
January 2002
avatar

for (var i in o) {
  println("o."+i+"="+o<i>);
}

But I recommend using venkman's debugger thing, it shows a whole tree and lets you set breakpoints and whatnot.

Marcello

ReyBrujo
Moderator
January 2001
avatar

Indeed. You can install it as a extension for Firefox.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Matthew Leverton
Supreme Loser
January 1999
avatar

Billybob
Member #3,136
January 2003

Thanks!

Another question while we're here. JavaScript is being its same old self...which is being a pain in the butt.

    var html = "<div style='position: absolute; width: 0px; height: 0px; border: 1px solid black;' id='div-id-" + div_id + "></div>";
    e.src.innerHTML = html + e.src.innerHTML;

Doesn't work right. For some really odd reason JS has decided to convert SOME, but not all, of html's string into html entities. Yes, only some. In particular everything after div-id= gets htmlentities run on it, up until the end of the html string. Everything that was originally in e.src.innerHTML is fine...well except for the fact that it's all corrupted now that there's broken HTML at the top of it.

e.src is:

if(event.target) e.src = target;

Part of a left mouse down event. In this case it's pointing at document.body.

Any ideas what's up?

Marco Radaelli
Member #3,028
December 2002
avatar

Aren't you missing a ' somewhere after div-id-?

Billybob
Member #3,136
January 2003

That is a DARN good point. Thanks!

Marco Radaelli
Member #3,028
December 2002
avatar

Hehe, these are the kind of things which make programming fun :)

Ceagon Xylas
Member #5,495
February 2005
avatar

Javascript is BS, dude.
No offense to any lovers of the code [even though I've only met one in my entire life, so I don't think there are many of you] but it is one of the worst languages I've ever programmed in.

Marcello
Member #1,860
January 2002
avatar

Then you clearly know nothing about the language. What's so bad about it? Disregarding crap implementations of it, of course.

nonnus29
Member #2,606
August 2002
avatar

Quote:

Javascript is BS, dude.
No offense to any lovers of the code [even though I've only met one in my entire life, so I don't think there are many of you] but it is one of the worst languages I've ever programmed in.

Don't confuse javascript with DOM weirdness either. Javascript (or the language defined by ECMA-262) is actually a really slick little language when you consider it on it's own.

CGamesPlay
Member #2,559
July 2002
avatar

Another important technique:
println(uneval(object));

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Ceagon Xylas
Member #5,495
February 2005
avatar

Well I guess now I've met 3. ^.^

CGamesPlay
Member #2,559
July 2002
avatar

You're confusing "people who love JS" with "people who posted since your last reply"...

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Ceagon Xylas
Member #5,495
February 2005
avatar

Haha well they defended it pretty strongly... Specially Marcello.

ReyBrujo
Moderator
January 2001
avatar

JS is good enough for what it needs to do. [Now, let's add fuel for the flame war] I believe it is not as "loved" because there aren't many good IDEs. [A bit more] And everyone knows nowadays programmers without an IDE are end users. [That last one was enough I believe ;)]

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

kentl
Member #2,905
November 2002

The biggest "flaw" of JavaScript IMHO is that Microsoft went the JScript route and thus made cross browser compatibility harder. Apart from that, language wars are always silly per definition. Use the right tool for the job.

Billybob
Member #3,136
January 2003

Quote:

I believe it is not as "loved" because there aren't many good IDEs

I disagree. I love PHP, and don't use any ides for it other than SciTE, which I use for every other language. An IDE makes a language easier to use by providing you with some helpful tools like parameter info and such, but it's not going to help a broken language.

Quote:

Apart from that, language wars are always silly per definition. Use the right tool for the job.

Except for the fact that JavaScript is the only tool for the job.

ReyBrujo
Moderator
January 2001
avatar

You are forgetting vbscript ;)

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Marcello
Member #1,860
January 2002
avatar

How can someone love PHP? What's so great about it? The syntax is ugly, the library is convoluted and unorganized, the class system is crap (maybe php5 is ok, but geez!). I'm slowly making the switch from PHP to JavaScript, and every second I am amazed at how much easier and faster it is to develop in.

Marcello

Thomas Fjellstrom
Member #476
June 2000
avatar

I'll be using ECMAScript in my GUI applications.. TrollTech has a nice library called QSA (Qt Script for Applications) which is an implementation of ECMAScript thats tied heavily into Qt, Anything you can do in C++ with Qt, you can do in QSA, and then some.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

kentl
Member #2,905
November 2002

Quote:

Except for the fact that JavaScript is the only tool for the job.

Did I say it wasn't? (Answer: No) :)

BAF
Member #2,981
December 2002
avatar

How can you use JavaScript in place of PHP? Unless you're using ASP or something.

Marcello
Member #1,860
January 2002
avatar

Like this.

kentl
Member #2,905
November 2002

I would like it to be possible to create a bitmap using JavaScript and set pixels within it, which AFAIK isn't yet possible.

 1   2 


Go to: