Skip to main content

Home/ javascript/ Group items tagged my

Rss Feed Group items tagged

Javier Neira

6 Advanced JavaScript Techniques You Should Know - 3 views

  • function showStatistics(args) { document.write("<p><strong>Name:</strong> " + args.name + "<br />"); document.write("<strong>Team:</strong> " + args.team + "<br />"); if (typeof args.position === "string") { document.write("<strong>Position:</strong> " + args.position + "<br />"); } if (typeof args.average === "number") { document.write("<strong>Average:</strong> " + args.average + "<br />"); } if (typeof args.homeruns === "number") { document.write("<strong>Home Runs:</strong> " + args.homeruns + "<br />"); } if (typeof args.rbi === "number") { document.write("<strong>Runs Batted In:</strong> " + args.rbi + "</p>"); } } showStatistics({ name: "Mark Teixeira" }); showStatistics({ name: "Mark Teixeira", team: "New York Yankees" }); showStatistics({ name: "Mark Teixeira", team: "New York Yankees", position: "1st Base", average: .284, homeruns: 32, rbi: 101 });
  • Object-oriented JavaScript implements namespace-like principles due to the fact that properties and methods are declared inside of objects, thus there are less likely to be conflicts. A conflict could arise, however, through object names. And very likely, the conflict will occur "silently", thus you may not be alerted to the issue immediately.
  • if (typeof MY == "undefined") { MY = new Object(); MY.CUSTOM = new Object(); } MY.CUSTOM.namespace = function() { function showStatistics(args) { document.write("<p><strong>Name:</strong> " + args.name + "<br />"); document.write("<strong>Team:</strong> " + args.team + "<br />"); if (typeof args.position === "string") { document.write("<strong>Position:</strong> " + args.position + "<br />"); } if (typeof args.average === "number") { document.write("<strong>Average:</strong> " + args.average + "<br />"); } if (typeof args.homeruns === "number") { document.write("<strong>Home Runs:</strong> " + args.homeruns + "<br />"); } if (typeof args.rbi === "number") { document.write("<strong>Runs Batted In:</strong> " + args.rbi + "</p>"); } } showStatistics({ name: "Mark Teixeira", team: "New York Yankees", position: "1st Base", average: .284, homeruns: 32, rbi: 101 }); } MY.CUSTOM.namespace();
  • ...1 more annotation...
  • Rendering Readable HTML
  •  
    //2. Object Literals to Pass Optional Arguments function showStatistics(args) { document.write("Name: " + args.name + "
    "); document.write("Team: " + args.team + "
    "); if (typeof args.position === "string") { document.write("Position: " + args.position + "
    "); } if (typeof args.average === "number") { document.write("Average: " + args.average + "
    "); } if (typeof args.homeruns === "number") { document.write("Home Runs: " + args.homeruns + "
    "); } if (typeof args.rbi === "number") { document.write("Runs Batted In: " + args.rbi + ""); } } showStatistics({ name: "Mark Teixeira" }); showStatistics({ name: "Mark Teixeira", team: "New York Yankees" }); showStatistics({ name: "Mark Teixeira", team: "New York Yankees", position: "1st Base", average: .284, homeruns: 32, rbi: 101 }); //Using Namespaces to Prevent Conflicts if (typeof MY == "undefined") { MY = new Object(); MY.CUSTOM = new Object(); } MY.CUSTOM.namespace = function() { function showStatistics(args) { .................. } showStatistics({ name: "Mark Teixeira", team: "New York Yankees", position: "1st Base", average: .284, homeruns: 32, rbi: 101 }); } MY.CUSTOM.namespace();
Javier Neira

Caffeinated Simpleton » Blog Archive » An Introduction to JavaScript's "this" - 2 views

  • That’s what this is expected to be, anyway. It’s expected to be a reference to the current instance of whatever object it’s defined within.
  • It’ll give an error saying that this doesn’t have a member called condiments, even though it clearly does. What happened?!
  • This is because there is no binding of functions to instances in JavaScript.
  • ...3 more annotations...
  • The setTimeout function, however, just has a reference to that function. When it calls it, it’s not aware of myHotDog, so JavaScript sets this to window
  • function HotDog() { var my = this; // my references the current this, which is correct. my.condiments = "mustard, ketchup"; my.getCondiments = function() { return my.condiments; //my is guaranteed to be a reference to the original "this" } }
  • In constructors, this is always your instance. So we created a new variable, my, that references the HotDog instance. This allows you to always refer to the HotDog instance, no matter how the getCondiments function is called.
Justin Pierce

The Most Excellent Bookkeeping Services - 1 views

started by Justin Pierce on 14 Feb 13 no follow-up yet
Justin Pierce

Enjoy An Excellent Bookkeeping Service - 1 views

It is a small grocery with just 4 staff that I started 6 months ago. I thought I can smoothly run it on my own. But then I noticed that I always encounter troubles in doing the payroll and other mo...

started by Justin Pierce on 28 Dec 12 no follow-up yet
seth kutcher

Fast and Reliable Computer Repair Services - 1 views

One day, I was working on my thesis which was due in three days and then suddenly my computer shut down. I then browsed for companies that offer computer repair services and found Computer Hardwar...

computer repair services

started by seth kutcher on 02 Nov 11 no follow-up yet
seth kutcher

The Best Remote PC Support I Ever Had - 1 views

The Remote PC Support Now excellent remote PC support services are the best. They have skilled computer tech professionals who can fix your PC while you wait or just go back to work or just simpl...

remote PC support

started by seth kutcher on 12 Sep 11 no follow-up yet
Javier Neira

JQuery HowTo: Create callback functions for your jQuery plugins & extensions - 1 views

  • $.extend({  myFunc : function(someArg, callbackFnk){    // do something here    var data = 'test';     // now call a callback function    if(typeof callbackFnk == 'function'){      callbackFnk.call(this, data);    }  }});$.myFunc(someArg, function(arg){  // now my function is not hardcoded  // in the plugin itself  // and arg = 'test'});
  •  
    $.extend({ myFunc : function(someArg, callbackFnk){ // do something here var data = 'test'; // now call a callback function if(typeof callbackFnk == 'function'){ callbackFnk.call(this, data); } } }); $.myFunc(someArg, function(arg){ // now my function is not hardcoded // in the plugin itself // and arg = 'test' });
Ivan Pavlov

Ajaxian » foreignObject: Hey, you've got HTML in my SVG! - 0 views

  •  
    The SVG foreignObject tag allows you to mix non-SVG content into your page. For example, you could drop some HTML in the middle of an SVG element.
Mike Chelen

Server-Side JavaScript Talk Slides & Source - 0 views

  •  
    It's well overdue, but I've finally managed to get this stuff up. Here are the slides from my presentation on Server-Side JavaScript, as well as the source code for the Jaxer REST API provider and consumers that I wrote.
Bartłomiej Małysz

Galleriffic | flickr like jQuery web gallery script - 0 views

  •  
    Galleriffic was inspired by Mike Alsup's Cycle plugin, but with performance in mind for delivering a high volume of photos. This is my first experiment with jQuery, so I would love feedback on how to improve this plugin. I am not so great at spelling, and it was much later that I realized that the more appropriate spellings would be Gallerific or Gallerrific, but is too late now for a name change, so Galleriffic remains.
yc c

HTML & JavaScript Encoder/Decoder - 1 views

  •  
    Encoding/Decoding Escape/Unescape These scripts are intended to explain how to "hide" HTML and/or javascript from other people who view your page's source code. It is not foolproof, but it does make it more difficult to read and understand the source code. Due to the nature of how these scripts work, the explanation may seem complicated and drawn out, but be patient and it should make sense once you gain a little experience with them. You don't really have to know the ins-and-outs of these scripts, but it does help you understand how and why they work. So, take a seat and I'll do my best to make this seem as un-complicated as possible.
Ace Dee

SEO Services that Exceeds Expectations - 1 views

Oracle Digital impressed me greatly with their content, knowledge and passion for the industry. After following Oracle Digital for three months and liking what I saw, I approached them for an initi...

SEO Perth Brisbane

started by Ace Dee on 21 Feb 11 no follow-up yet
Justin Pierce

Managing Finances Gets Easier - 1 views

started by Justin Pierce on 27 Nov 12 no follow-up yet
Felipp Crawly

Thank You OPS - 1 views

started by Felipp Crawly on 03 Jan 13 no follow-up yet
Muhammad Saqib

How can I get my website on the top of search engine? - 0 views

  •  
    Articles from SHAHZAIB KHATRI - Creating a website is a bit easier in the sense that you know what type of website you want to design & can acquire services of a website designer. But the tough part is to promote it to the masses as
Mike Chelen

JavaScript & MySQL With Jaxer - 0 views

  •  
    Wouldn't it be cool if you could work with MySQL within your JavaScript code? Think about it, you wouldn't have to spend extra time writing extra server-side code for connecting to, querying, and parsing results, you could just write a little bit more code in your JavaScript and be done with it. Of course, we wouldn't want any of this SQL exposed to the end-user, as that would be a major security issue, but what if that problem was solved as well? You might also raise the point that you'd still need the ability to prepare your SQL statements that take dynamic input to prevent SQL injection attacks, but if that weren't an issue, wouldn't that be awesome as well?
Tim McMichael

If you need to suggest 1 site to learn Javascript, which one will it be? - 9 views

I like this topic. If everybody suggest something, then we could create a nice collection. My list: 1. Douglas Crockford javscript videos - http://yuiblog.com/crockford/ 2. Douglas Crockford javas...

javascript tutorial question

1 - 19 of 19
Showing 20 items per page