7
I have two functions
/########### CARREGAR - LANÇAMENTO ###########/
var carregar_parametros=function(){
alert('asd');
}
/########### CADASTRAR - LANÇAMENTO ###########/
var cadastrar_parametro=function(){
if($("#lancamento").val()!=''){
UiLoading.show();
$.post('/paginas/teste/cadastrar_parametro',{
lancamento:$("#lancamento").val(),
tipo:$("#tipo").val(),
ativo:$("#lancamento_ativo").attr('checked')=='checked' ? '1' : '0'
},function(){
carregar_parametros();
UiLoading.hide();
$("#cancelar_parametro").click()
UiAlert('Parâmetro cadastrado com sucesso!','Atenção');
});
}else{
UiAlert('Por favor, preencha os campos nulos!','Atenção');
}
}
when I do the job cadastrar_parametro
with the comment
/########### CADASTRAR - LANÇAMENTO ###########/
there is no mistake but when I do the function carregar_parametros
with the same style of comment it gives error
Uncaught Syntaxerror: Unexpected token ILLEGAL
And when I test the extension firebug from Firefox he shows me this
Syntaxerror: illegal Character /########### REGISTER - RELEASE
#####/
What can it be?
JS comments should not be // for a line, /**/ for multi-line?
– Omni
@Omni yes, but a while ago I tested with this kind of comment and it worked
– Silvio Andorinha
@Silvioandorinha, if it worked for some time, I do not know, but this is not a standard form of comment in javascript. And I see no problem in using the common javascript comment:
/*########### CARREGAR - LANÇAMENTO ###########*/
, I don’t see why you want to invent =/.– Fernando Leal
perhaps the
/## algo ##/
is interpreted as a regex– rray
@Silvioandorinha when looking at the jsfiddle you can notice that the first / (before pressing parameter) is being considered as a character. What does not happen in the next /## (before registering parameter). Anyway I think it would be good practice to use the form of JS comments.
– Omni
@Fernando is not irrelevant! This type of doubt is common to anyone when learning a new programming language.
– user7261
@Fernando knowledge of language is never irrelevant and I bet you didn’t know it was possible to make comments this way
– Silvio Andorinha
@The point is that there is no documentation to prove that the comments can be made in this way (at least I can not find). And as the question implies, doing so causes strange behavior.
– Omni
@Silvioandorinha, this is not a form of javascript comment, as demonstrated in this link, which Andrey quoted. And that question seems to me a little bit forced, because that kind of comment is not necessary, and I believe you already knew that before you even asked here.
– Fernando Leal
@Fernando is not necessary more is possible, maybe this can be even a javascript error and this is the first post that talks about this strange behavior, and is not decontextualized because the question is very clear.
– Silvio Andorinha
@Silvioandorinha the way you write the comment is interpreted in the Javascript language as a regular expression as in the Guilhermebernal answer, this is not a standard comment your question is really decontextualized because the title is "Comment types" and what you proposed here as a type of comment does not exist and anyone who is "learning" javascript will know this when he finds this post he will just get confused with his type "Regex/Comment", this is not a mistake! is the same thing as you ask why an exe does not open in Lion or is not how it works
– Tuyoshi Vinicius
@Tuyoshivinicius and decontextualized says :
Essa pergunta não parece ser sobre programação, dentro do escopo definido na central de ajuda.
-- She really isn’t programming ??????– Silvio Andorinha
@Tuyoshi What is obvious to you is not obvious to anyone else. If you see a code that uses this syntax to write a comment (which is in passing works and is perfectly valid as long as the semicolons are in place), it is fair to ask how it happened. Especially if the person does not know regular expressions. This is a syntax that he has never seen before and behaves like a comment. By your logic, that question should also be closed, right? http://answall.com/questions/14788/a-sintaxe-tem-algum-significado-especial
– Guilherme Bernal