Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-05-2012, 01:01 AM   PM User | #16
donna1
New Coder

 
Join Date: Nov 2012
Location: london
Posts: 55
Thanks: 5
Thanked 1 Time in 1 Post
donna1 can only hope to improve
Code:
What could you even do without HTML and CSS in javascript?
with html5 canvas you can draw and write text and everything in javascript.
It can be interactive too and do moving graphics.

the only other thing I may need is PHP to read and write to a database on a server, it seems a shame that javascript cant do that directly?

Last edited by donna1; 12-05-2012 at 01:04 AM..
donna1 is offline   Reply With Quote
Old 12-05-2012, 01:03 AM   PM User | #17
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,579
Thanks: 62
Thanked 4,063 Times in 4,032 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
I have to admit that I would never bother to use === for something like this:
Code:
			if(tileTopCount===map[x].length){
I mean, we *KNOW* that both of those values are numbers. The one because we made it so, the other because the .length property is guaranteed to be so.

So why do we need to test that the types are equal?

If JavaScript were more sensitive to what === means, I might be more inclined to use it. For example, if === distinguished between integers and non-integers. But it doesn't, because JavaScript doesn't see a distinction between them.

I commonly only use === when I'm comparing against something being returned by some function and where I can't guarantee the type being returned.

Still, it's a nice operator to have in your arsenal.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 12-05-2012, 01:06 AM   PM User | #18
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,579
Thanks: 62
Thanked 4,063 Times in 4,032 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
Originally Posted by donna1 View Post
with html5 canvas you can draw and write text and everything in javascript.
It can be interactive too and do moving graphics.
Yes. And it's overkill in probably more than half the things I see it being used for.

And it's no substitute for many HTML tags and CSS properties.

For example, if you draw text on a canvas, then that text is SET at the number of pixels you used when you drew it.

If I put HTML text on a page, using CSS such as
Code:
<span style="font-size: x-large;">Headline</span>
then the browser user can easily cause the font size to grow or shrink, so it can be much more user-friendly to, say, people with limited vision.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 12-05-2012, 01:08 AM   PM User | #19
donna1
New Coder

 
Join Date: Nov 2012
Location: london
Posts: 55
Thanks: 5
Thanked 1 Time in 1 Post
donna1 can only hope to improve
I really dont like this ===

I dont agree with even the two distinctions of = and ==
That caused me loads of bugs last week before I realised they are completely different

Another stupid idea from someone, who has probably wasted combined millions of hours in errors since
donna1 is offline   Reply With Quote
Old 12-05-2012, 01:12 AM   PM User | #20
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,579
Thanks: 62
Thanked 4,063 Times in 4,032 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
Originally Posted by donna1 View Post
[CODE]
the only other thing I may need is PHP to read and write to a database on a server, it seems a shame that javascript cant do that directly?
So PHP can also draw on canvases, creating images that can then be just dropped into an HTML page.

Except for animation, why learn to even use JavaScript? Or why learn to create HTML with PHP? Just use PHP to create images and never learn anything more.

Sorry, but pfui. You remind me of the ranks and ranks of COBOL programmers who never learned anything else and are now stuck doing nothing but maintaining ancient legacy code. Or the steam engine repairmen who refused to learn diesel engines. Or the scribes who refused to learn how to work a printing press. Or...

Learn as much as you possibly can!

I've been programming for over 40 years now, and I *STILL* try to learn something new as often as possible. New languages, new techniques, new tricks for better database efficiency, etc., etc., etc.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 12-05-2012, 01:12 AM   PM User | #21
pdiddles03
New Coder

 
Join Date: Jun 2010
Posts: 76
Thanks: 0
Thanked 1 Time in 1 Post
pdiddles03 is an unknown quantity at this point
Quote:
Originally Posted by donna1 View Post
I really dont like this ===

I dont agree with even the two distinctions of = and ==
That caused me loads of bugs last week before I realised they are completely different

Another stupid idea from someone, who has probably wasted combined millions of hours in errors since
How is it stupid? = means you are setting a value for something. For the Majority of the time I use === not ==.

I can tell you really don't know a lot about programming in Javascript.
pdiddles03 is offline   Reply With Quote
Old 12-05-2012, 01:13 AM   PM User | #22
pdiddles03
New Coder

 
Join Date: Jun 2010
Posts: 76
Thanks: 0
Thanked 1 Time in 1 Post
pdiddles03 is an unknown quantity at this point
oh and == and === means you are comparing
pdiddles03 is offline   Reply With Quote
Old 12-05-2012, 01:13 AM   PM User | #23
pdiddles03
New Coder

 
Join Date: Jun 2010
Posts: 76
Thanks: 0
Thanked 1 Time in 1 Post
pdiddles03 is an unknown quantity at this point
One last thing, How come I have to load my page twice for my map to display?
pdiddles03 is offline   Reply With Quote
Old 12-05-2012, 01:14 AM   PM User | #24
donna1
New Coder

 
Join Date: Nov 2012
Location: london
Posts: 55
Thanks: 5
Thanked 1 Time in 1 Post
donna1 can only hope to improve
OPendant I agree that it is slightly harder in javascript to increase font size, as you have to set the text style as a string of "font + size pt"
Not logical, should just be a fontsize = number, but still its not that difficult to change with a sting
donna1 is offline   Reply With Quote
Old 12-05-2012, 01:15 AM   PM User | #25
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,579
Thanks: 62
Thanked 4,063 Times in 4,032 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
Originally Posted by donna1 View Post
I really dont like this ===

I dont agree with even the two distinctions of = and ==
That caused me loads of bugs last week before I realised they are completely different

Another stupid idea from someone, who has probably wasted combined millions of hours in errors since
So presumably you would like the PASCAL solution better?

Pascal uses := for assignment and = for comparison.

And it's just as easy there to make the mistake of using = when you meant := as it is to make the JavaScript/Java/C/C++/C#/PHP (and other languages!!!!) mistake of using = when you meant ==.

If you REALLY want confusion, use BASIC, which only has =. And what do you think
Code:
    A = B = C = 7
means in BASIC??

HINT: A will get a value of FALSE. Probably.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 12-05-2012, 01:18 AM   PM User | #26
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,579
Thanks: 62
Thanked 4,063 Times in 4,032 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
Originally Posted by donna1 View Post
OPendant I agree that it is slightly harder in javascript to increase font size, as you have to set the text style as a string of "font + size pt"
Not logical, should just be a fontsize = number, but still its not that difficult to change with a sting
** WRONG **

Yes, your JAVASCRIPT code can COMPLETELY REDRAW the canvas, assuming you code like that and assuming you choose to change the fontsize number.

The BROWSER USER can *NOT* cause that to happen unless you give her/him some way to REQUEST the change in font size.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 12-05-2012, 01:19 AM   PM User | #27
donna1
New Coder

 
Join Date: Nov 2012
Location: london
Posts: 55
Thanks: 5
Thanked 1 Time in 1 Post
donna1 can only hope to improve
You put the word IF before a comparison and LET before an assignment and you can use = in both cases.
donna1 is offline   Reply With Quote
Old 12-05-2012, 01:19 AM   PM User | #28
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,579
Thanks: 62
Thanked 4,063 Times in 4,032 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
Originally Posted by pdiddles03 View Post
One last thing, How come I have to load my page twice for my map to display?
Because you coded something wrong?

How can we guess without seeing your code?
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 12-05-2012, 01:20 AM   PM User | #29
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,579
Thanks: 62
Thanked 4,063 Times in 4,032 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
Originally Posted by donna1 View Post
You put the word IF before a comparison and LET before an assignment and you can use = in both cases.
Sure about that?

Code:
LET A = B = C = 7
Only the first = there is an assignment!
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 12-05-2012, 01:24 AM   PM User | #30
donna1
New Coder

 
Join Date: Nov 2012
Location: london
Posts: 55
Thanks: 5
Thanked 1 Time in 1 Post
donna1 can only hope to improve
yes well in my language you couldnt have a statement like A=B=C=7
doesnt make any sense anyway
if you want them all to be 7
LET A=7;
LET B=A;
LET c=A;
donna1 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:31 AM.


Advertisement
Log in to turn off these ads.