I'm developing mobile applications using Visual Studio 2017 and Apache Cordova. I've always coded using JQuery and Javascript however i have never written a code using Typescript.
When searching the web almost everyone is using Typescript with Ionic. (thinking of starting to benefit and use the Ionic Framework) Is it the same if i use JQuery or Javascript instead of Typescript with Ionic?
Or its recommended that i learn Typescript and start using it with Ionic?
Thank you for the clarification.
This is how i usually write the code for Cordova using JQuery:
function shuffleArray(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
return array;
}
function beginGame() {
$('#info').hide();
var level = 0;
$('#game_title h2').html('Level 1');
$('#game_question h3').html('What is the most common language?');
$('#game_body').html('');
var gameBody = document.getElementById('game_body');
var columnAnswer, buttonAnswer;
var answers = [['Arabic', ''], ['Spanish', ''], ['English', 'right_answer'], ['Chinese', '']];
var arr = shuffleArray(answers);
console.log(arr);
for (var i = 0; i < arr.length; i++) {
columnAnswer = document.createElement('div');
columnAnswer.className = 'col-xs-12';
buttonAnswer = document.createElement('button');
buttonAnswer.id = 'answer_button_'+i;
buttonAnswer.className = 'btn btn-primary btn-sx answer_button ' + arr[i][1];
buttonAnswer.type = 'button';
buttonAnswer.innerHTML = arr[i][0];
//buttonAnswer.setAttribute('onclick', 'onQuoteClick(' + quotes[i].id + ')');
console.log(buttonAnswer);
columnAnswer.appendChild(buttonAnswer);
gameBody.appendChild(columnAnswer);
}
$('.answer_button').click(function () {
var button_id = $(this).attr('id');
if ($('#' + button_id).hasClass('right_answer')) {
//alert('Right Answer');
$('#info').show();
fillInformation();
} else {
alert('Wrong Answer');
}
});
}
function fillInformation() {
$('#game_title h2').html('English');
$('#info_image img').attr("src", './images/level_1.png');
$('#info_text h5').html('English Language');
}
noImplicitAnyorstrictNullChecks, you can just use regular JavaScript in .ts files. Using TypeScript also has no effect on what libraries (like jQuery) you can use.