These are chat archives for FreeCodeCamp/HelpJavaScript

29th
Dec 2018
Pagnito
@Pagnito
Dec 29 2018 01:55
hey whats a good cloud postgres cloud service i can try that has a good free plan similar to atlasDB or what use to be mlab
Pagnito
@Pagnito
Dec 29 2018 02:14
i think elephant sql will do
Idowu Wasiu
@Hoxtygen
Dec 29 2018 02:22
Hi guys,
@JLuboff how you doing?
I've got database question I need help on
Idowu Wasiu
@Hoxtygen
Dec 29 2018 02:30

I have three tables; books, authors and categories
books have author_id and category_id column
authors have author_id and author_name column
categories have category_id and category_name column

in books table, instead of writing authors name and category name I simply reference them with author_id and category_id respectively.

here's the problem, when submitting a form for new book, I populate the category with category_name because I thought it doesn't make sense to populate it with numbers. what do i need to do to translate the category_name to category_id in the database? because the category_id column in the book table is expecting an integer....

Jason Luboff
@JLuboff
Dec 29 2018 04:27
The point of the ID being an integer is that it consumes less storage than a character string. If you were just going to use the category_name field, than you really don’t need separate tables but the reason we have separate tables is that we can have a one to many relationship, it conforms to (at least) the third normal form of normalization, uses less storage as a category name could be repeated (and an integer uses less storage than a string) and helps with indexing. It’s a bit more work but results in a happy relational database 😁
Spyrantis Theodoros
@thodorisanta
Dec 29 2018 15:00

hi guys, so i tried in my codepen the following code

function makeObj() { return { x: 1 }; }
var myObj = new makeObj();
console.log(myObj);

and the outcome as expected was Object { x: 1 }

the i tried the same code but without the new keyword and i noticed that the outcome was still the same. Why is that? and why do i need the new keyword if the outcome is the same?

Henry
@GitHub-Henry
Dec 29 2018 15:06
this may help
Pagnito
@Pagnito
Dec 29 2018 15:41
internet explorer still doesnt support fetch?
Jason Luboff
@JLuboff
Dec 29 2018 15:53
IE will never support it, it’s not a supported browser anymore
Spyrantis Theodoros
@thodorisanta
Dec 29 2018 16:18
so it has to do with the prototype?
Aditya
@ezioda004
Dec 29 2018 16:34
@thodorisanta new keyword is a quite different mechanism. If your function have return then new keyword will first create a new instance object from that constructor function and would...do nothing with it.
Spyrantis Theodoros
@thodorisanta
Dec 29 2018 16:46
@ezioda004 what if the function doesnt have a return?
Aditya
@ezioda004
Dec 29 2018 16:49
@thodorisanta You will have an extra object in the prototype chain:
function makeObj() { 
  this.x = 1;
}
var myObj = new makeObj();
myObj.__proto__ === makeObj.prototype; // true
myObj.__proto__.__proto__ === Object.prototype; // true
Thats JS way of inheriting
enestatli
@enestatli
Dec 29 2018 17:06
hello
Aditya
@ezioda004
Dec 29 2018 17:07
:wave:
enestatli
@enestatli
Dec 29 2018 17:07
I kept getting this error while getting data from wikipedia
Failed to load resource: net::ERR_NAME_NOT_RESOLVED
in my console
var displayWikipediaData = function () {
    var searchString = $('#searchString').val();
    var wikipediaUrl = "https://en.wikipedia.org/w/api.php?action=opensearch&search="+ searchString + "&format=json&callback=wikiCallback";

    $.ajax({
        url: wikipediaUrl,
        dataType: "jsonp",
        jsonp: "callback",
        success: function(res) {
            console.log(res);
        }
    });

    return false;
}

$('#form').submit(displayWikipediaData);
Pagnito
@Pagnito
Dec 29 2018 17:09
anyone play with webassembly yet?
Pagnito
@Pagnito
Dec 29 2018 18:29
found these nod docs, that seem to go into mored detail, makes it alot easier to learn node