Jump to content

L8V2L

Members
  • Posts

    788
  • Joined

  • Last visited

Posts posted by L8V2L

  1. Animation in Javascript is done by using setInterval() or setTimeout() to manipulate an element's style periodically.

    Yes but, those are inefficient <~~~ I know efficient mean work right... so to be inefficient mean that it doesn't work as efficient, but something that work to efficient take up energy and cpu that could be use for other important task action... JSG comment is... confusing me.... um.... um...They say that requestanimtaionframe is better, and I agree for which it was made for as the name imply... so in sense their is only one animation function.
  2. Which one seem more implantable <~~~ AM I using that correctly?

    <!DOCTYPE html><html><body><p>Click the button to call the new myMet() method, and display this month's name, using the new myProp property.</p><button onclick="myFunction()">Try it</button><p id="demo"></p><script>Date.prototype.myMet = function() {switch(this.getMonth()){case 0: {this.myProp = "January"};break;case 1: {this.myProp = "February"};break;case 2: {this.myProp = "March"};break;case 3: {this.myProp = "April"};break;case 4: {this.myProp = "May"};break;case 5: {this.myProp = "June"};break;case 6: {this.myProp = "July"};break;case 7: {this.myProp = "August"};break;case 8: {this.myProp = "Spetember"};break;case 9: {this.myProp = "October"};break;case 10:{this.myProp = "November"};break;case 11:{this.myProp = "December"};break; //<~~~ crap, forgot the last break when I sent it.}}function myFunction() {var d = new Date();d.myMet();document.getElementById("demo").innerHTML = d.myProp;}</script></body></html>
    or
    <!DOCTYPE html><html><body><p>Click the button to call the new myMet() method, and display this month's name, using the new myProp property.</p><button onclick="myFunction()">Try it</button><p id="demo"></p><script>Date.prototype.myMet = function() {if (this.getMonth() == 0){this.myProp = "January"};if (this.getMonth() == 1){this.myProp = "February"};if (this.getMonth() == 2){this.myProp = "March"};if (this.getMonth() == 3){this.myProp = "April"};if (this.getMonth() == 4){this.myProp = "May"};if (this.getMonth() == 5){this.myProp = "June"};if (this.getMonth() == 6){this.myProp = "July"};if (this.getMonth() == 7){this.myProp = "August"};if (this.getMonth() == 8){this.myProp = "Spetember"};if (this.getMonth() == 9){this.myProp = "October"};if (this.getMonth() == 10){this.myProp = "November"};if (this.getMonth() == 11){this.myProp = "December"};}function myFunction() {var d = new Date();d.myMet();document.getElementById("demo").innerHTML = d.myProp;}</script></body></html>
    refer to this:http://www.w3schools.com/jsref/jsref_prototype_date.aspIf you ask me, this is like comparing statement two in an for statement;
    ;i < array.length;
    vs
    var I=0, n = arry.length; i > n; 
    I sent an email to switch it... no pun indented.
  3. the site and wiki for coffeescript seem to cover your second questionhttp://coffeescript.org/http://en.wikipedia.org/wiki/CoffeeScript regarding the first question, I guess it depends. I haven't used it, but then I like Javascript the way it is, good and bad. As a developer, I focus on enhancing the good parts and filtering out the not so good parts. but you can google for blogs and see what the pro and cons are for yourself.https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=opinions%20on%20coffeescript&safe=off

    I don't understand that?!?!?!?!? WHAT IS THE BAD PART ABOUT JAVASCRIPT!?!?!?!? ... To me... it's prefect... I guess cause I'm just getting into the program world, and JavaScript alone with a few other language I'm studying.. I don't know much yet to really say that... but still to me, JavaScript is awesome as it is. other language have been built on top of JavaScript; for a lightweight language that's powerful.What about svg's animation? SVG been around a lot longer then canvas, and it just doesn't make sense to me for how choppy the animation is... a least in my browser.
  4. Why must there be a way? In order to do that you need a static variable, and Javascript doesn't have static variables.

    Because it's magic JSG! YOU...(turn away hanging my head, with sorrow in my eyes) you just don't understand. Because... Because it's magic. (turn back toward you, with strength and determination in my eyes) And I will never give up!Pokémon first season theme song instrumental playing:I wanna be the very best,Like no programmer ever was.To learn JavaScript is my real quest,To master it is my cause.I will read over the materials,Searching for more and broaden my mind.Each concept to understandThe power that is codeJavaScript, (gotta learn it all) its you and meI know its my destinyJavaScript, oh, you're my best friendIn a application we must defendJavaScript, (gotta learn it all) a heart so trueOur courage will pull us throughYou teach me and I'll teach youJa-va-Script, gotta learn it allEvery material along the wayWith courage I will faceI will learn every dayTo master the languageCome with me, the time is rightThere's no better teamArm in arm we'll learn the languageIt's always been our dreamJavaScript!(Gotta learn it all)It's you and meI know it's my destinyJavaScript!Oh, you're my best friend,In a application we must defend.JavaScript!A heart so true.Our courage will pull us through.You teach me and I'll teach you.JavaScript!(Gotta learn it all)x5Yeah!JavaScript!It's you and meI know it's my destinyJavaScript!Oh, you're my best friend,In a application we must defend.JavaScript!A heart so true.Our courage will pull us through.You teach me and I'll teach you.JAVASCRIPT!
  5. Note the word "as". It is a simile. It executes the function as if it were a method of the object. It does not actually make it a method of the object.I doubt you'll understand this, because you seem to get into things you don't understand yet, but specifically what it does is execute the function in the scope of an object.

    I understand. It act as an Object's, or in apply case, as an Array's method. Thank you, if I have read more carefully, I would have notice that... probably not... I don't know.
  6. No.

    With call() or apply() you can set the value of this, and invoke a function as a new method of an existing object. <~~~ I copy and paste this off w3s tutorials function section; Invocation page. If no then what does it mean/saying?
  7. I'm just bewildered...

    :crazy: .... :huh: What is wrong with me experimenting? This is for practice and discovery. On that note:
    //Original code: var add = (function () {    var counter = 0;    return function (x) {return counter+=x}})()add(10);add(15);document.getElementById("demo").innerHTML = add(20);//What I'm trying to do; there must be away to do it like this:function add(x) {         var counter = counter || 0;    function count(x) {return counter+=x;}   return(count(x));}add(2);add(2);
  8. function foo(foo, bar) {     return foo * bar; }var baz = myFunction.call(this, 10, 2);var foobar = foo.call(Object, 10, 2);console.log(foobar + "n" + baz);function bar(foo, bar) {     return foo * bar; }myArray = [10,2]; var foobaz = bar.apply(Array, [10, 2]);   // 	Will also return 20 var foo0 = bar.apply(Array, [10, 2]);   // 	Will also return 20 console.log(foobaz + "n" + foo0);/*Went over this in the 'js pocket reference' book, but I been seen apply, and call. I guess different transaltion is good. Still favorite the manaul, docuemnt, guide sltye. But this isn't really about the Function's method; call, and apply, this is about 'this'.*//*With call() or apply() you can set the value of this, and invoke a function as a new method of an existing object. <~~~~ So this make the function an method of an object? Please yes or no.*/
  9. why are you over complicating it? Do you even know how a simple ternary operator works? Both your examples are extremely convoluted and impractical for a real life application (and from what I can see won't even work). As we keep saying, keep it simple until you understand the language and know what you're doing at a basic level first.

    function checkSecretWord(guess){  var isCorrectGuess = guess === 'w3schools' ? 'Correct' : 'Incorrect guess, try again';   return isCorrectGuess;} console.log(checkSecretWord('mdn'));  //logs 'Incorrect guess, try again'console.log(checkSecretWord('microsoft'));  //logs 'Incorrect guess, try again'console.log(checkSecretWord('w3schools'));  //logs 'Correct'

     

    This is for (What I want to do) thing... Please take no offense to that, what I'm basically saing is that I came across an example, that use an if statement in place of the ternary I put in there, I put in the ternary cause I wanted to, as I was trying to figure out the correct logic that should be apply to these ternary to work. I though of other option, as in switch statement, and else if... switch statement would win if this was a real application... really a switch statement in another function would win to refer to it... or better yet the || logic... Why did you write that... now I have to:
    function checkSecretWord(guess){  var isCorrectGuess = guess;  var is = "";(isCorrectGuess === 'w3s') ? (is ='Correct, guess is w3s') : (isCorrectGuess === 'mdn') ? (is = 'Correct, guess is mdn') : (isCorrectGuess === 'w3c') ? (is = 'Correct, guess is w3c') : (is = 'Incorrect guess, try again');   return isCorrectGuess + " " + "is" + " " + is;} console.log(checkSecretWord('mdn'));  //logs 'mdn is Correct, guess is mdn'console.log(checkSecretWord('w3c'));  //logs 'w3c is Correct, guess is w3c'console.log(checkSecretWord('w3s'));  //logs 'w3s is Correct, guess is w3s'console.log(checkSecretWord('microsoft')) //logs 'microsoft is Incorrect guess, try again'
    Please be careful... What I mean is, your bless if you are born with (refer to signature that will refer you to picture), that you are only born with that, or something doesn't manifest from that... Your lucky.I just see it as more practice. When I start writing code that I'm going to use for application; robust is the goal... The main goal is to get it to work, the goal after that is to make it as robust as possible. As someone said to me on this forum, I took that that to value and go by it as a philosophy to programming, and go by it.... No more, must get back to learning. BYE!
  10. it's also a good practice to initialize your variables to a default value, ideally one indicative of the data type it's going store, especially in the case of a loosely typed language like Javascript.

    question 1) So if the variable x is going to hold a string value down the line. When declare, it'll be good practice to initialize it with a empty string value <-- Is that what you are saying?question 2) do this for only primitive values?question 3) Or both primitive, and composition values? Composition; for object {}, and for array [], and even for function... maybe not for function .Please answer all with yes or no, and if other please put at bottom of the replies which should be either yes or no.... <~~~ I hope this isn't seem as demanding. I'm just making sure of clarity for my sake.
  11. I like to alter the code sometimes when I go through the tutorial; as I am going through w3s js tutorial. And reading books on js, and etc.

    (1 == 0) ? (a = "yes: 1 == 0") : (1 < 0) ? (a = "yes 1 < 0") : (1 <= 0) ? (a = "1 <= 0") : (0 >= 1) ? (a = "0 >= 1") : (a = "none of thee preceder"); console.log(a);var x = undefined, y = x;function myFunction(x, y) {(x == undefined && y == undefined) ? (x = 2, y = 12) : (x == undefined) ? (x = 12) : (y == undefined) ? (y = 2) : (x = x, y = y);   return x * y;}//document.getElementById("demo").innerHTML = myFunction();console.log(myFunction());
    Multiple times, I wanted to post here for an answer, but I knew if it turn out to be simple, I would feel less. So for two hours or three, or maybe two and a half I spent trying to figure this out.How to concatenate multiple ternaries together. The problem was how I was arranging the condition of the conat-ternaries.I deserve a like... a point. Please someone give me a point for this simple, non-meaningful(concept in learning) trail....It doesn't matter if I figure it out by myself, the fact of how long it took me to get it right is defeat enough to make me feel less.
  12. cars = ["BMW", "Volvo", "Saab", "Ford"];var i = 2;var len = cars.length;var text = ""; // <~~~ Why the empty string again?for (; i < len; i++) {    text += cars[i] + "<br>";}    var text = ""; // <~~~    var i = 0;    while (i < 10) {        text += "<br>The number is " + i;        i++;}
  13. You're able to use it in any environment that uses Javascript. Whether or not it's a good idea is another thing.

    So why would Mozilla declare it as so? Or better yet, why would one not use it?
  14. Is English your native language? You seem to have trouble understanding what things are saying.

    /* Using test */var a = str.test(exp);alert(a); // Shows "true" or "false"/* Equivalent operation: */var a = true;var e = str.exec(exp);if(e === null) {    a = false;}alert(a); // Shows "true" or "false", the same value as it would in the previous example

     

    /* Using test */var str = "js";var exp = /"js"/var a = exp.test(str); alert(a); // Shows "true" or "false"/* Equivalent operation: */var a = true;var e = exp.exec(str);if(e === null) {    a = false;}alert(a); // Shows "true" or "false", the same value as it would in the previous example
    Yes... cause of my (refer to signature which will refer you to pic)...
  15. What they're saying is correct. Calling test() is the same as first calling exec() and then returning true if the exec() return value isn't null.

    Maybe I don't understand it in that content... You calling test is the same as FIRST calling exec(); calling them both? You're saying while calling them both, exec() first? That what it look like.
  16. Calling test() is equivalent to calling exec() and returning true if the return value of exec() is not null. Because of this equivalence, the test() method behaves the same way as the exec() method when invoked for a global regular expression: it begins searching the specified string at the position specified by lastIndex, and if it finds a match, it sets lastIndex to the position of the character immediately following the match. Thus, you can loop through a string using the test() method just as you can with the exec() method.No it's not! exec(); return an array of items, or null. test(); return a Boolean value!!!!!!! MMMMMMMMMMAAAAAAAAAAAAAWWWWWW!!!!!!!!

×
×
  • Create New...